﻿<phone:PhoneApplicationPage xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit.Own"
                            xmlns:Microsoft_Phone_Controls_Maps="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls" mc:Ignorable="d"
                            d:DesignWidth="480" d:DesignHeight="800" x:Class="AuchanScan.Views.MapPage" Orientation="Portrait">

  <phone:PhoneApplicationPage.Resources>
    <Style x:Key="ButtonStyle1" TargetType="Button">
      <Setter Property="Background" Value="Transparent" />
      <Setter Property="BorderBrush" Value="{StaticResource PhoneForegroundBrush}" />
      <Setter Property="Foreground" Value="{StaticResource PhoneForegroundBrush}" />
      <Setter Property="BorderThickness" Value="{StaticResource PhoneBorderThickness}" />
      <Setter Property="FontFamily" Value="{StaticResource PhoneFontFamilySemiBold}" />
      <Setter Property="FontSize" Value="{StaticResource PhoneFontSizeMediumLarge}" />
      <Setter Property="Padding" Value="10,3,10,5" />
      <Setter Property="Template">
        <Setter.Value>
          <ControlTemplate TargetType="Button">
            <Grid Background="Transparent">
              <VisualStateManager.VisualStateGroups>
                <VisualStateGroup x:Name="CommonStates">
                  <VisualState x:Name="Normal" />
                  <VisualState x:Name="MouseOver" />
                  <VisualState x:Name="Pressed">
                    <Storyboard>
                      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                     Storyboard.TargetName="ContentContainer">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneBackgroundBrush}" />
                      </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualState>
                  <VisualState x:Name="Disabled">
                    <Storyboard>
                      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground"
                                                     Storyboard.TargetName="ContentContainer">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PhoneDisabledBrush}" />
                      </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualState>
                </VisualStateGroup>
              </VisualStateManager.VisualStateGroups>
              <ContentControl x:Name="ContentContainer" ContentTemplate="{TemplateBinding ContentTemplate}"
                              Content="{TemplateBinding Content}" Foreground="{TemplateBinding Foreground}"
                              HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}"
                              VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" />
            </Grid>
          </ControlTemplate>
        </Setter.Value>
      </Setter>
    </Style>
    <ControlTemplate x:Key="PushpinControlTemplate1" TargetType="Microsoft_Phone_Controls_Maps:Pushpin">
      <Grid x:Name="ContentGrid">
        <VisualStateManager.VisualStateGroups>
          <VisualStateGroup x:Name="VisualStateGroup">
            <VisualState x:Name="Selected">
              <Storyboard>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                               Storyboard.TargetName="textBlock">
                  <DiscreteObjectKeyFrame KeyTime="0">
                    <DiscreteObjectKeyFrame.Value>
                      <Visibility>Visible</Visibility>
                    </DiscreteObjectKeyFrame.Value>
                  </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)"
                                               Storyboard.TargetName="stackPanel">
                  <DiscreteObjectKeyFrame KeyTime="0">
                    <DiscreteObjectKeyFrame.Value>
                      <Visibility>Visible</Visibility>
                    </DiscreteObjectKeyFrame.Value>
                  </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.TextWrapping)"
                                               Storyboard.TargetName="textBlock_Copy">
                  <DiscreteObjectKeyFrame KeyTime="0">
                    <DiscreteObjectKeyFrame.Value>
                      <TextWrapping>Wrap</TextWrapping>
                    </DiscreteObjectKeyFrame.Value>
                  </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
                <DoubleAnimation Duration="0" To="16" Storyboard.TargetProperty="(TextBlock.FontSize)"
                                 Storyboard.TargetName="textBlock_Copy" d:IsOptimized="True" />
                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(TextBlock.FontFamily)"
                                               Storyboard.TargetName="textBlock_Copy">
                  <DiscreteObjectKeyFrame KeyTime="0">
                    <DiscreteObjectKeyFrame.Value>
                      <FontFamily>Segoe WP</FontFamily>
                    </DiscreteObjectKeyFrame.Value>
                  </DiscreteObjectKeyFrame>
                </ObjectAnimationUsingKeyFrames>
              </Storyboard>
            </VisualState>
            <VisualState x:Name="Base" />
          </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Button BorderThickness="0" Click="Button_Click" Style="{StaticResource ButtonStyle1}">
          <StackPanel Orientation="Vertical">
            <Grid Background="{TemplateBinding Background}" MinHeight="31" MinWidth="29">
              <StackPanel x:Name="stackPanel" Visibility="Collapsed" Margin="12,0">
                <TextBlock x:Name="textBlock" Text="{Binding Name}" MaxWidth="250" FontSize="21.333" Foreground="White"
                           HorizontalAlignment="Left" TextWrapping="Wrap" />
                <TextBlock x:Name="textBlock_Copy" MaxWidth="250" Text="{Binding Description}" FontSize="16"
                           TextWrapping="Wrap" FontFamily="Segoe WP" Foreground="White" />
                <!--
                <HyperlinkButton Content="{Binding Localizedresources.More, Source={StaticResource LocalizedStrings}}" Click="HyperlinkButton_Click" HorizontalAlignment="Right">
								<HyperlinkButton.Foreground>

									<SolidColorBrush Color="#FF318F91"/>


								</HyperlinkButton.Foreground>
							</HyperlinkButton>
              -->
              </StackPanel>
            </Grid>
            <Polygon Fill="{TemplateBinding Background}" Points="0,0 29,0 0,29" Width="29" Height="29"
                     HorizontalAlignment="Left" />
          </StackPanel>
        </Button>
      </Grid>
    </ControlTemplate>
    <DataTemplate x:Key="PlaceDataTemplate">
      <Grid Margin="0,6">
        <Grid.RowDefinitions>
          <RowDefinition Height="auto" />
          <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
          <ColumnDefinition Width="*" />
          <ColumnDefinition Width="auto" />
        </Grid.ColumnDefinitions>
        <Border HorizontalAlignment="Left" Width="8" Margin="0,3" Grid.RowSpan="2"
                Background="{StaticResource AccentBrushMagasin}" />

        <TextBlock Text="{Binding Name}" FontSize="32" Margin="16,0,0,0" Foreground="Black" />
        <TextBlock Text="{Binding Address}" TextWrapping="Wrap" MaxHeight="44" FontSize="16" Opacity="0.6" Grid.Row="1"
                   Margin="16,0,0,0" Grid.ColumnSpan="2" Foreground="Black" />
      </Grid>
    </DataTemplate>
    <ControlTemplate x:Key="CenterPushpinControlTemplate" TargetType="Microsoft_Phone_Controls_Maps:Pushpin">
      <Ellipse Fill="#FF26888B" Width="16" Height="16" Margin="-8,0,0,-8" />
    </ControlTemplate>

  </phone:PhoneApplicationPage.Resources>
  
  <phone:PhoneApplicationPage.ApplicationBar>
    <shell:ApplicationBar IsVisible="False" ForegroundColor="White"
                          Opacity="1">
      <shell:ApplicationBarIconButton IconUri="/icons/around.png" Click="AroundMeApplicationBarIconButton_Click"
                                      IsEnabled="True" Text="search around" />
      <shell:ApplicationBarIconButton IconUri="/icons/center.png" Click="CenterApplicationBarIconButton_Click"
                                      IsEnabled="True" Text="me localiser" />
    </shell:ApplicationBar>
  </phone:PhoneApplicationPage.ApplicationBar>
  <phone:PhoneApplicationPage.FontFamily>
    <StaticResource ResourceKey="PhoneFontFamilyNormal" />
  </phone:PhoneApplicationPage.FontFamily>
  <phone:PhoneApplicationPage.FontSize>
    <StaticResource ResourceKey="PhoneFontSizeNormal" />
  </phone:PhoneApplicationPage.FontSize>
  <phone:PhoneApplicationPage.Foreground>
    <StaticResource ResourceKey="PhoneForegroundBrush" />
  </phone:PhoneApplicationPage.Foreground>

  <Grid>
    <Grid.Background>
      <ImageBrush Stretch="Fill" ImageSource="/images/Page_Background.png" />
    </Grid.Background>
    <controls:Pivot x:Name="autour" Background="#00000000" Foreground="White">
      <controls:PivotItem Header="carte" Margin="12,44,12,0">
        <Microsoft_Phone_Controls_Maps:Map x:Name="MyMap" ZoomLevel="14"
                                           CredentialsProvider="AkWDwJ45XSHt5lG4Q5iZ5P6zINhrkM9eEunfOs-t-pTEx53wK14uz5R6s15LI4Ra" RenderTransformOrigin="0.5,0.5"
                                           Margin="12,0,12,12">
          <Microsoft_Phone_Controls_Maps:Pushpin Location="{Binding CenterMap}"
                                                 Template="{StaticResource CenterPushpinControlTemplate}" />

          <Microsoft_Phone_Controls_Maps:MapItemsControl x:Name="MapStations" ItemsSource="{Binding Places}">
            <Microsoft_Phone_Controls_Maps:MapItemsControl.ItemTemplate>
              <DataTemplate>
                <Microsoft_Phone_Controls_Maps:Pushpin Location="{Binding Location}"
                                                       Template="{StaticResource PushpinControlTemplate1}" />

              </DataTemplate>
            </Microsoft_Phone_Controls_Maps:MapItemsControl.ItemTemplate>
          </Microsoft_Phone_Controls_Maps:MapItemsControl>

        </Microsoft_Phone_Controls_Maps:Map>
      </controls:PivotItem>
      <controls:PivotItem Header="liste" Margin="12,44,12,0">
        <Grid>
          <ListBox ItemsSource="{Binding Places}" SelectionChanged="ListBox_SelectionChanged"
                   ItemTemplate="{StaticResource PlaceDataTemplate}" ItemContainerStyle="{StaticResource StretchListBoxItemStyle}" Margin="12,0" />
        </Grid>
      </controls:PivotItem>
    </controls:Pivot>
    <Image Height="64" Source="/images/herbe.png" Stretch="Fill" VerticalAlignment="Bottom" Margin="0,0,0,8"/>
    <Rectangle Fill="{StaticResource AccentBrushMagasin}" Height="8" VerticalAlignment="Bottom"/>
  </Grid>
</phone:PhoneApplicationPage>
